import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/components/main/app_bar.dart';
import 'package:flutter_eve_plugin/constants/constant.dart';
import 'package:flutter_eve_plugin/pages/main/constant.dart';
import 'package:flutter_eve_plugin/pages/ye_xiu/login/actions.dart';
import 'package:flutter_eve_plugin/plugin/main.dart';
import 'package:flutter_eve_plugin/route/main.dart';
import 'package:flutter_eve_plugin/store/base_action.dart';
import 'package:flutter_eve_plugin/store/main.dart';
import 'package:flutter_eve_plugin/store_vm/app_vm.dart';
import 'package:flutter_eve_plugin/store_vm/ye_xiu/login/main.dart';
import 'package:flutter_eve_plugin/store_vm/ye_xiu/main.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';
import 'package:flutter_redux/flutter_redux.dart';

class LoginBootMachinePage extends StatefulWidget {
  final String title;

  LoginBootMachinePage({Key key, this.title}) : super(key: key);

  @override
  _LoginBootMachinePageState createState() => _LoginBootMachinePageState();
}

class _LoginBootMachinePageState extends State<LoginBootMachinePage> {
  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, AppStateViewModel>(onInit: (store) {
      PluginEve.sendMessage(PluginConstant.httpAccountInfo, httpType: HttpType.POST).then((data) {
        if (data==null)return;
        store.dispatch(BaseAction(type: YX_LOGIN_DISPATCH, data: data));
        inputPhone(store, store.state.accountInfoState.accountInfo.mobile);
      });
    }, converter: (store) {
      return AppStateViewModel(
          state: store.state,
          yeXiuStateViewModel: YeXiuStateViewModel(
              loginStateViewModel: LoginStateViewModel(bootMachineNext: () {
            Navigator.pushNamed(context, RouteConstant.LoginInputWIFIPage);
          })));
    }, builder: (context, vm) {
      return Scaffold(
        backgroundColor: Colors.white,
        appBar: buildAppBar(context,
            type: FigureIP.YE_XIU, colors: [Colors.white, Colors.white]),
        body: Container(
          height: MediaQuery.of(context).size.height,
          width: MediaQuery.of(context).size.width,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Container(
                padding: EdgeInsets.only(left: setRatio(30), top: setRatio(20)),
                child: Text(
                  '点击电源键开机',
                  style: TextStyle(
                      fontSize: setTextSp(24),
                      color: Color((0xFF333333)),
                      fontWeight: FontWeight.bold),
                ),
              ),
              Container(
                padding: EdgeInsets.only(left: setRatio(30), top: setRatio(16)),
                child: Text(
                  '长期连通电源，我们才能提供更好的服务\n请不要断开充电器',
                  style: TextStyle(
                      fontSize: setTextSp(15), color: Color((0xFF333333))),
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: setRatio(23)),
                width: setRatio(375),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      width: setRatio(345),
                      height: setRatio(345),
                      child: Image.asset(
                        imageUtilYeXiu('login/icon_machine@2x'),
                      ),
                    ),
                    SizedBox(
                      height: setRatio(10),
                    ),
                    Text(
                      '电源按键在设备的背后',
                      style: TextStyle(
                          color: Color(0xFF333333), fontSize: setTextSp(15)),
                    )
                  ],
                ),
              ),
              Expanded(child: Container()),
              GestureDetector(
                onTap:
                    vm.yeXiuStateViewModel.loginStateViewModel.bootMachineNext,
                child: Container(
                  margin: EdgeInsets.only(
                      left: setRatio(30),
                      right: setRatio(30),
                      bottom: setRatio(22)),
                  height: setRatio(46),
                  decoration: BoxDecoration(
                      borderRadius:
                          BorderRadius.all(Radius.circular(setRatio(5))),
                      gradient: LinearGradient(
                          colors: [Color(0xFF0386FF), Color(0xFF03AAFF)],
                          begin: Alignment(0.5, 0),
                          end: Alignment(0.5, 1))),
                  child: Center(
                    child: Text(
                      '已看到人物，下一步',
                      style: TextStyle(
                          fontSize: setTextSp(17), color: Color(0xFFFFFFFF)),
                    ),
                  ),
                ),
              )
            ],
          ),
        ),
      );
    });
  }
}
